package com.demo.entity;

import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
@Table(name="coursesection")
public class CourseSection {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	Long id;
	String chapter;

	@JsonIgnore
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name="refCourseID")
	Course course;
	
	@ManyToMany(fetch = FetchType.EAGER)
	@JoinTable(name = "coursechapter", //中间表名
		joinColumns = {@JoinColumn(name="refChaptertId",referencedColumnName = "id")}, //配置中间表的外键指向主表1的PK
		inverseJoinColumns = {@JoinColumn(name="refCourseId",referencedColumnName = "id")}) //配置中间表的外键指向主表2的PK
	Set<CourseWare> courseWares;
	
	public Course getCourse() {
		return course;
	}
	public void setCourse(Course course) {
		this.course = course;
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getChapter() {
		return chapter;
	}
	public Set<CourseWare> getCourseWares() {
		return courseWares;
	}
	public void setCourseWares(Set<CourseWare> courseWares) {
		this.courseWares = courseWares;
	}
	public void setChapter(String chapter) {
		this.chapter = chapter;
	}
	
}
